package com.qzsf.backend.controller;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.service.RegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/21 10:07 周四
 * @Email 1429278462@qq.com
 * @Remark 报名控制器
 * @Version 1.0
 */
@RestController
@RequestMapping("/registrations")
public class RegistrationController {
    @Autowired
    private RegistrationService registrationService;
    @GetMapping
    public Result getRegistration(@RequestParam(required = false) Integer status,@RequestParam(required = false) String userName,@RequestParam(required = false) String eventName,@RequestParam int pageNo,@RequestParam int pageSize){
        return registrationService.getRegistration(status, userName, eventName,pageNo, pageSize);
    }

    @PostMapping("/approve")
    public Result registrationBatchApprove(@RequestBody List<Integer> ids){
        return registrationService.batchApprove(ids);
    }

    @PostMapping("/reject")
    public Result registrationBatchReject(@RequestBody List<Integer> ids){
        return registrationService.batchReject(ids);
    }

    //创建报名
    @PostMapping("/{eventId}")
    public Result createUserRegistration(@PathVariable int eventId){
        return registrationService.createRegistration(eventId);
    }

    //获取当前已报名用户
    @GetMapping("/user/{eventId}")
    public Result getEventRegisteredUser(@PathVariable int eventId){
        return registrationService.getEventRegisteredUser(eventId);
    }

    //获取当前活动未审核报名
    @GetMapping("/unchecked/{eventId}")
    public Result getEventUncheckedRegistration(@PathVariable int eventId){
        return registrationService.getEventUncheckedRegistration(eventId);
    }

    @PutMapping("cancel/{eventId}")
    public Result cancelRegistration(@PathVariable int eventId){
        return registrationService.cancelRegistration(eventId);
    }


}
